#include<bits/stdc++.h>
using namespace std;
double t,n,m,l,vs;
double d,v,a;
bool c[100010];
struct node{
    double l1,r1;
}dis[100010];
double p[100010];
bool k1[100010];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int k=0,eras=0;
    cin>>t;
    while(t--)
    {
        k=0,eras=0;
        cin>>n>>m>>l>>vs;
        for(int i=1;i<=n;i++)
        {
            cin>>d>>v>>a;
            if(v>vs&&(a>0||a==0))
            {
                dis[i].l1=d;
                dis[i].r1=l;
            }
            else if(v>vs&&a<0)
            {
                double x=(vs*vs-v*v)/(2*a);
                dis[i].l1=d;
                dis[i].r1=d+x;
            }
            else if((v<vs||v==vs)&&(a<0||a==0))
            {
                dis[i].l1=-1;
                dis[i].r1=-1;
            }
            else if((v<vs||v==vs)&&a>0)
            {
                double x=(vs*vs-v*v)/(2*a);
                dis[i].l1=d+x;
                dis[i].r1=l;
            }
        }
        int s=0;
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
            for(int j=1;j<=n;j++)
            {
                if((p[i]>dis[j].l1&&p[i]<dis[j].r1)||p[i]==dis[j].l1||p[i]==dis[j].r1)
                {
                    if(k1[j]==0)
                        k++;
                    k1[j]=1;
                    s++;
                }
            }
        }
        cout<<k<<" "<<s-6<<endl;
    }
    return 0;
}
